﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOAModels;
using TarreOA.TarreOABLL;

public partial class DiscussArea_Index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.DataList_DataTable();
        }
    }

    protected void DataList1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            string daid = ((HtmlInputHidden)e.Item.FindControl("HidDaId")).Value;
            ((LinkButton)e.Item.FindControl("LbtIn")).Attributes.Add("da_id", daid);
        }
    }

    private void DataList_DataTable()
    {
        DiscussAreaService daService = new DiscussAreaService();
        DataTable dt = new DataTable();
        dt.Columns.Add("DiscussAreaId", typeof(string));
        dt.Columns.Add("DiscussAreaName", typeof(string));
        dt.Columns.Add("DiscussAreaCreateTime", typeof(string));
        List<DiscussArea> list = daService.findALL();
        if (list != null && list.Count > 0)
        {
            foreach (DiscussArea da in list)
            {
                DataRow dr = dt.NewRow();
                dr["DiscussAreaId"] = da.DiscussAreaId.ToString();
                dr["DiscussAreaName"] = da.DiscussAreaTitle;
                dr["DiscussAreaCreateTime"] = da.DiscussAreaCreateTime.ToString();
                dt.Rows.Add(dr);
            }
        }
        if (dt.Rows.Count > 0)
        {
            this.DataList1.DataSource = dt.DefaultView;
        }
        else
        {
            this.DataList1.DataSource = null;
        }
        this.DataList1.DataBind();
    }
    protected void LbtIn_Click(object sender, EventArgs e)
    {
        string da_id = ((LinkButton)sender).Attributes["da_id"];
        Response.Redirect("DiscussIndex.aspx?da_id=" + da_id);
    }
}
